<template>
<view class="page__bd">
	<custom-navbar bgColor="bg-white shadow" :isBack="true" :isHome="true">
		<block slot="backText">返回</block>
		<block slot="content">店铺详情</block>
	</custom-navbar>
	<view class="daui-media daui-media_appmsg daui-media_product bg-white" v-if="shopInfo.id > 0">
		<view class="daui-media__hd">
			<image :src="shopInfo.logo" mode="widthFix"></image>
		</view>
		<view class="daui-media__bd">
			<view class="daui-media__title">{{shopInfo.name}}</view>
			<view class="daui-media__work">
				<view class="daui-disinline text-pink margin-right-sm">
					<text class="iconfontzz icon-favor_fill margin-right-xs"></text>{{shopInfo.score}}
				</view>
				<view class="daui-disinline">月销量：{{shopInfo.month_sale_num}}</view>
			</view>
			<view class="daui-media__work">{{shopInfo.address}}</view>
		</view>
	</view>
	<view class="daui-card">
		<view class="classify-card" v-if="index_exhibition_mode == 1">
			<block v-for="(item, index) in productList" :key="index">
				<view class="classify-card_item">
					<view class="daui-media daui-media_appmsg daui-media_product bg-white" hover-class="hover" :hover-start-time="150">
						<view class="cart-check">
							<evan-checkbox :custom="item.pid" v-model="item.isCart" primaryColor="#eb0909" @change="onProductChange"></evan-checkbox>
						</view>
						<view class="daui-media__bd">
							<view class="daui-media__banner">
								<image :src="item.picurl" mode="scaleToFill" :style="{'height':imgExhibitionHeight+'px'}" @click="openProductDetail(item.pid)"></image>
							</view>
							<view class="classify-card_content">
								<view class="daui-media__prodtitle">{{item.name}}</view>
								<view class="daui-media__work">{{item.subtitle}}</view>
								<view class="daui-media__tag" v-if="item.attrtag_num > 0">
									<view v-for="(itemTag, indexTag) in item.attrtag" class="daui-badge daui-badge-sm" :class="itemTag.color">
										{{itemTag.name}}
									</view>
								</view>
								<view class="daui-flex">
									<view class="daui-flex__item">
										<text class="text-red">{{item.real_price}}</text>
									</view>
									<view class="daui-flex__item text-right">
										<text class="text-gray">已售{{item.sale_num}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>
		<view class="waterfall-card" v-else-if="index_exhibition_mode == 2">
			<view class="waterfall-card_item">
				<block v-for="(item, index) in productList" :key="index">
					<view class="daui-media daui-media_appmsg daui-media_product shadow bg-white" hover-class="hover" :hover-start-time="150">
						<view class="cart-quickcheck">
							<evan-checkbox :custom="item.pid" v-model="item.isCart" primaryColor="#eb0909" @change="onProductChange"></evan-checkbox>
						</view>
						<view class="daui-media__bd">
							<view class="daui-media__banner">
								<image :src="item.picurl" mode="widthFix"></image>
							</view>
							<view class="waterfall-card_content">
								<view class="daui-media__title" @click="openProductDetail(item.pid)">{{item.name}}</view>
								<view class="daui-media__work">{{item.subtitle}}</view>
								<view class="daui-media__tag" v-if="item.attrtag_num > 0">
									<view v-for="(itemTag, indexTag) in item.attrtag" class="daui-badge daui-badge-sm" :class="itemTag.color">
										{{itemTag.name}}
									</view>
								</view>
								<view class="daui-flex">
									<view class="daui-flex__item">
										<text class="text-red">{{item.real_price}}</text>
									</view>
									<view class="daui-flex__item text-right">
										<text class="text-gray">已售{{item.sale_num}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</block>
			</view>
			<view class="waterfall-card_item">
				<block v-for="(item, index) in productList2" :key="index">
					<view class="daui-media daui-media_appmsg daui-media_product shadow bg-white" hover-class="hover" :hover-start-time="150">
						<view class="cart-quickcheck">
							<evan-checkbox :custom="item.pid" v-model="item.isCart" primaryColor="#eb0909" @change="onProductChange"></evan-checkbox>
						</view>
						<view class="daui-media__bd">
							<view class="daui-media__banner">
								<image :src="item.picurl" mode="widthFix"></image>
							</view>
							<view class="waterfall-card_content">
								<view class="daui-media__title" @click="openProductDetail(item.pid)">{{item.name}}</view>
								<view class="daui-media__work">{{item.subtitle}}</view>
								<view class="daui-media__tag" v-if="item.attrtag_num > 0">
									<view v-for="(itemTag, indexTag) in item.attrtag" class="daui-badge daui-badge-sm" :class="itemTag.color">
										{{itemTag.name}}
									</view>
								</view>
								<view class="daui-flex">
									<view class="daui-flex__item">
										<text class="text-red">{{item.real_price}}</text>
									</view>
									<view class="daui-flex__item text-right">
										<text class="text-gray">已售{{item.sale_num}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</block>
			</view>
		</view>
		<view v-else-if="index_exhibition_mode == 3">
			<block v-for="(item, index) in productList" :key="index">
				<view class="daui-media daui-media_appmsg daui-media_product bg-white" hover-class="hover" :hover-start-time="150" @tap="openProductDetail(item.pid)">
					<view class="daui-media__hd">
						<image :src="item.picurl" mode="scaleToFill" lazy-load="true" class="daui-media__thumb"></image>
					</view>
					<view class="daui-media__bd">
						<view class="daui-media__title">{{item.name}}</view>
						<view class="daui-media__work">{{item.subtitle}}</view>
						<view class="daui-media__tag" v-if="item.attrtag_num > 0">
							<view v-for="(itemTag, indexTag) in item.attrtag" class="daui-badge daui-badge-sm" :class="itemTag.color">
								{{itemTag.name}}
							</view>
						</view>
						<view class="margin-top-xs">
							<text class="text-price text-red text-xl">{{item.real_price}}</text>
							<text class="text-price text-gray text-del text-sm margin-left-xs">{{item.origin_price}}</text>
						</view>
						<view class="flex justify-between align-end">
							<view class="flex align-center flex-sub">
								<view class="text-gray text-sm flex-sub">已售{{item.sale_num}}</view>
							</view>
							<view class="padding-left-xl text-right">
								<button class="daui-btn bg-primary round shadow daui-btn_sm"><text class="icon-lightfill"> </text>抢购</button>
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>
		<view class="daui-load" :class="!loadding?'loading':'over'"><view class="daui-load-in"><view class="daui-nomore-text"></view></view></view>
	</view>
	
	<uni-popup ref="kefuewmPopup">
		<view class="daui-dialog daui-dialog_lg padding-xl">
			<view class="kefu-pop">
				<view class="kefu-pop-top">
					<image :src="this.shopInfo.kefuewm"></image>
				</view>
			</view>
			<button class="daui-btn bg-red block round" @click="hideKefuewmPopup">确定</button>
		</view>
	</uni-popup>
	
	<!-- 底部操作条 -->
	<view class="daui-tabbar daui-tabbar-fixed solid-top">
		<view class="daui-tabbar__hd daui-tabbar__bd-left" @click="openShopcart" style="display: none;">
			<view class="iconfontzz icon-cart">
				<view class="daui-badge badge" v-if="cartNum">
					<text class="uni-tab__dot"><span>{{cartNum}}</span></text>
				</view>
			</view>
			购物车
		</view>
		<view class="daui-tabbar__hd daui-tabbar__bd-left" @click="openChatDetail" style="display: none;">
			<view class="iconfontzz icon-service"></view>
			客服
		</view>
		<view class="daui-tabbar__bd" @click="onShare">
			<button class="daui-btn bg-blue"><view class="iconfontzz icon-share1"></view>分享</button>
		</view>
		<view class="daui-tabbar__bd" @click="openShopcart">
			<button class="daui-btn bg-primary"><view class="iconfontzz icon-zd-gouwuche"></view>去结算</button>
		</view>
	</view>
	<view class="daui-tabbar-height"></view>
	
	<!-- 选择商品规格 -->
	<uni-popup ref="specbox" type="bottom">
		<specificationsnew @submitCart="submitCart" @submitBuy="submitBuy" :productInfo="productInfo" :gspecList="gspecList" @hidePopup="hidePopup" v-if="specOnLoad == 1"></specificationsnew>
	</uni-popup>
	
	<!-- 购物车 -->
	<uni-popup ref="shopcart" type="bottom">
		<view class="bg-white">
			<view class="daui-cell daui-cell_sm">
				<view class="daui-cell__bd">已选商品</view>
				<view class="daui-cell__ft" @tap="doClearCart">
					<text class="iconfontzz icon-shanchu"></text>清空
				</view>
			</view>
			<scroll-view scroll-y="true" class="cart-popup-scroll">
				<block v-for="(item,index) in cartList" :key="index">
					<view class="daui-media daui-media_appmsg cart-list">
						<view class="daui-media__bd">
							<view class="daui-media__title">{{item.prod_name}}</view>
							<view class="daui-media__work" v-if="item.spec_1">
								规格：<text>{{item.spec_1}}</text>
								<text v-if="item.spec_2">，{{item.spec_2}}</text>
							</view>
							<view class="flex margin-top-xs">
								<view class="flex-sub">
									<text class="text-red text-df" v-if="item.limit_minimum">{{item.limit_minimum}}{{item.unit}}起订：{{item.one_price}}元/{{item.unit}}</text>
									<text class="text-red text-df" v-else>{{item.one_price}}元/{{item.unit}}</text>
								</view>
								<view class="flex-sub">
									<view class="cart-input-box">
										购买数量<input type="number" name="mobile" v-model="item.buy_num" class="cart-input" placeholder="请输入数量" @input="numInput" />{{item.unit}}
									</view>
									<view class="text-red" v-if="item.buy_num">小计：{{floatMul(item.one_price, item.buy_num)}}</view>
								</view>
							</view>
						</view>
					</view>
				</block>
			</scroll-view>
		</view>
		<view class="daui-tabbar">
			<view class="daui-tabbar__bd daui-tabbar__price">
				实付款
				<text class="text-price text-lightred margin-left-xs">{{cartTotalPrice}}</text>
			</view>
			<view class="daui-tabbar__hd daui-tabbar__submit">
				<button @click="doShopcartBatchBuyNum">提交订单</button>
			</view>
		</view>
	</uni-popup>
	
	<!-- 分享弹窗 -->
	<uni-popup ref="sharePopup" type="bottom">
		<share-btn :sharedataTemp="sharedata"></share-btn>
	</uni-popup>
	
	<!--toast提示-->
	<daui-toast ref="toast"></daui-toast>
</view>
</template>

<script>
import http from "../../server/api-shop.js";
import danceuiTool from '../../utils/danceuiTool';
import numberTool from '../../utils/numberTool';
import specificationsnew from '@/components/specificationsnew/specificationsnew';
import lxcCount from '@/components/lxc-count/lxc-count.vue';
import mpHtml from '@/components/mp-html/mp-html'
var _self;
export default {
	components: {
		specificationsnew,
		lxcCount,
		mpHtml
	},
	data() {
		return {
			tagStyle: {'img':'float:left'},
			platform: '',
			webviewStyles: {
				progress: {
					color: '#FF3333'
				}
			},
			currentTab: 0,
			shid: 0,
			shopInfo: {},
			sharedata: {
				type: 1,
				strShareTitle: "分享标题",
				strShareSummary: "分享总结",
				strShareUrl: "https://www.xdffresh.com",
				strShareImageUrl: "https://www.xdffresh.com/appres/icon.png"
			},
			pictureList: [],
			procateList: [],
			productList: [],
			productList2: [],
			loadding: false,
			pullUpOn: true,
			index_exhibition_mode: 0,
			imgExhibitionHeight: 0,
			followShow: '',
			nav: [{name: '商品'}, {name: '评价'}, {name: '商家'}],
			TabCur: 0,
			TabCurProcate: 0,
			productInfo: [],
			specOnLoad: 0,
			gspecList: {}, //商品sku信息
			timer: 0,
			cartNum: 0,
			cartTotalPrice: 0,
			cartList: [],
			//evaluationList: [],
			modalEwm: false
		}
	},
	onLoad(options) {
		console.log('shopDetail,onLoad的参数:', options);
		_self = this;
		uni.getSystemInfo({
			success: function(res) {
				_self.platform = res.platform;
			}
		})
		this.shid = options.shid;
		this.list_param = {shid: this.shid};
	},
	onReady(){
		this.getData();
		//console.log('gspecList：', this.gspecList);
	},
	onPullDownRefresh(){
		console.log('=====上拉刷新refresh');
		this.list_param = {...this.list_param, p:1}
		this.getData();
		setTimeout(() => {
			uni.stopPullDownRefresh()
		}, 200);
	},
	methods: {
		async getData(){ //请求并获取数据
			console.log('toast:', this.$refs.toast)
			//获取用户登陆信息
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			let ret = await http.shopDetail(this.$refs.toast, this.list_param, headers, 1);
			var retData = ret.data;
			console.log('shopDetail页面,获取到的数据：', retData);
			this.shopInfo = retData.shopInfo;
			if(retData.shareInfo){
				this.sharedata.strShareTitle = retData.shareInfo.title;
				this.sharedata.strShareSummary = retData.shareInfo.desc;
				this.sharedata.strShareUrl = retData.shareInfo.link;
				if(retData.shareInfo.icon){
					this.sharedata.strShareImageUrl = retData.shareInfo.icon;
				}
			}
			console.log('sharedata:', this.sharedata);
			this.pictureList = retData.pictureList;
			//this.procateList = retData.procateList;
			this.index_exhibition_mode = retData.index_exhibition_mode;
			if(retData.index_exhibition_mode == 1){
				this.productList = retData.productList;
			}else{
				this.productList = retData.productList;
				this.productList2 = retData.productList2;
			}
			this.imgExhibitionHeight = this.windowWidth * retData.exhibition_ratio; //图片高度计算
			console.log('windowWidth:'+this.windowWidth+';商品列表图片高度imgExhibitionHeight:'+this.imgExhibitionHeight);
			this.cartBuyNum = retData.cartBuyNum;
			uni.setNavigationBarTitle({
				title: retData.shopInfo.name
			});
			// //todo
			// console.log('productList前:', this.productList)
			// const tmpProd = this.productList;
			// console.log('tmpProd:', tmpProd)
			// this.productList[2].name = 'test';
			// console.log('productList后:', this.productList)
			// //todo
			// console.log('platform前:', this.platform)
			// this.platform = 'test';
			// console.log('platform后:', this.platform)
		},
		// async tabSelect(e) {
		// 	this.TabCur = e.currentTarget.dataset.idx
		// 	console.log('this.TabCur:', this.TabCur);
		// 	if(this.TabCur == 0) {
				
		// 	}else if(this.TabCur == 1) {
		// 		//获取用户登陆信息
		// 		const token = uni.getStorageSync('token');
		// 		let headers = {"Authorization":"Bearer "+token};
		// 		let retData = await http.getEvaluation(this.$refs.toast, this.list_param, headers);
		// 		console.log('shopDetail页面,获取到的数据：', retData);
		// 		this.evaluationList = retData.evaluationList;
		// 	}else if(this.TabCur == 2) {
		// 		//获取用户登陆信息
		// 		const token = uni.getStorageSync('token');
		// 		let headers = {"Authorization":"Bearer "+token};
		// 		let retData = await http.getShopProfile(this.$refs.toast, this.list_param, headers);
		// 		console.log('shopDetail页面,获取到的数据：', retData);
		// 	}
		// },
		async getProductList(e){ //请求并获取数据
			this.TabCurProcate = e.currentTarget.dataset.idx;
			let id = e.currentTarget.dataset.id;
			console.log('getProductList,id:', id);
			//获取用户登陆信息
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			let param = {
				shid: this.shid,
				procateId: id
			};
			let ret = await http.getProductList(this.$refs.toast, param, headers);
			var retData = ret.data;
			console.log('getProductList,获取到的数据：', retData);
			this.productList = retData.productList;
		},
		async doFollow(){ //请求并获取数据
			//获取用户登陆信息
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			let ret = await http.doFollow(this.$refs.toast, this.list_param, headers, 1);
			var retData = ret.data;
			console.log('doFollow请求,获取到的数据：', retData);
			if(typeof retData != "undefined"){
				if(retData.flag == 1){
					uni.showModal({
						cancelText: '关闭',
						confirmText: '查看',
						title: '提示',
						content: retData.msg,
						success: function (res) {
							if (res.confirm) {
								uni.navigateTo({
									url: '/pagesA/mine/myShopFollow'
								});
							} else if (res.cancel) {
							}
						}
					});
					this.followShow = '已关注';
				}else if(retData.flag == 2){
					danceuiTool.showToast(this.$refs.toast, retData.msg);
					if(this.shopInfo.follow_num){
						this.followShow = '+关注'+this.shopInfo.follow_num;
					}else{
						this.followShow = '+关注';
					}
				}
			}
		},
		openProductIndex(shid) {
			uni.navigateTo({
				url: '/pages/product/productList?shid='+shid
			});
		},
		openProductDetail(pid) {
			uni.navigateTo({
				url: '/pages/product/productDetail?pid='+pid
			});
		},
		openLocation(){
			console.log('=====openLocation,latitude:'+this.shopInfo.latitude+';longitude:'+this.shopInfo.longitude);
			console.log('platform:', this.platform);
			uni.openLocation({
				latitude: Number(this.shopInfo.latitude),
				longitude: Number(this.shopInfo.longitude),
				name: this.shopInfo.name,
				address: this.shopInfo.address,
				success: function(){
					//danceuiTool.showToast('店铺的经度longitude：' + this.shopInfo.longitude);
					console.log('openLocation,success');
				},
				fail: function(err){
					console.log('openLocation,err:', JSON.stringify(err));
					danceuiTool.showToast('', 'err:'+JSON.stringify(err));
				}
			});
		},
		async onProductChange(currentValue, index, custom){
			console.log('=====currentValue:', currentValue);
			console.log('参数custom:', custom);
			//获取用户登陆信息
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			if(currentValue == true){
				var param = {
					initPid: custom,
					buyOrAdd: 2,
					initBuyNum: 0
				};
				let ret = await http.doAddAndUpdateCart(this.$refs.toast, param, headers);
				if(ret.code == 200){
					var retData = ret.data;
					if(retData.cartNum > 0){
						this.bottomCart = true;
					}
				}
			}else{
				var param = {
					initPid: custom,
					buyOrAdd: 1,
					initBuyNum: 0
				};
				let ret = await http.doAddAndUpdateCart(this.$refs.toast, param, headers);
				if(ret.code == 200){
					var retData = ret.data;
					if(retData.cartNum > 0){
						this.bottomCart = true;
					}
				}
			}
		},
		numInput(e){
			console.log('numInput');
			//this.InputBottom = 0
			//numberTool.FloatMul(item.one_price, item.buy_num)}
			var cartTotalPrice = 0;
			for(var key in this.cartList){
				cartTotalPrice += numberTool.FloatMul(this.cartList[key].one_price, this.cartList[key].buy_num);
			}
			this.cartTotalPrice = cartTotalPrice;
		},
		floatMul(one_price, buy_num){
			console.log('floatMul'+one_price+buy_num);
			return numberTool.FloatMul(one_price, buy_num);
		},
		//批量更新购物车商品数量
		async doShopcartBatchBuyNum(){
			console.log('cartList:', this.cartList);
			//获取用户登陆信息
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			let param = {
				shid: this.shid,
				cartNumList: this.cartList
			};
			let ret = await http.doShopcartBatchBuyNum(this.$refs.toast, param, headers);
			if(ret.code == 200){
				uni.navigateTo({
					url: '/pages/order/orderPrepair?initShid='+this.shid
				})
			}
		},
		async openOrderPrepair(){
			//获取用户登陆信息
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			let param = {
				shid: this.shid
			};
			let ret = await http.doShopcartVerify(this.$refs.toast, param, headers);
			var retData = ret.data;
			if(typeof retData != "undefined"){
				uni.navigateTo({
					url: '/pages/order/orderPrepair?initShid='+this.shid
				})
			}
		},
		/**
		 * 加入购物车
		 */
		async changeNum(realvalue, index, customId, customPid) {
			var that = this;
			console.log('changeNum,realvalue:'+realvalue+';index:'+index+';customId:'+customId+';customPid:'+customPid);
			this.numberValue = realvalue;
			// this.dataList[e.index].buyNum = e.value
			// setTimeout(() => {
			// 	this.calcHandle()
			// }, 0)
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			if(customPid){
				var param = {
					initPid: customPid,
					buyOrAdd: 1,
					buyNum: realvalue
				};
			}else{
				var param = {
					cartId: customId,
					buyOrAdd: 1,
					buyNum: realvalue
				};
			}
			let ret = await http.doAddAndUpdateCart(this.$refs.toast, param, headers, 1);
			var retData = ret.data;
			console.log('doAddAndUpdateCart操作,请求数据:', retData);
			if(typeof retData != "undefined"){
				if(customId){ //购物车里面增减数据的情况
					//更新购物车列表
					if(retData.cartList){
						//this.cartList.splice(index, 1); //去除该购物车数据
						this.cartList = retData.cartList;
						console.log('this.cartList:', this.cartList);
					}
					//更新商品列表(方式一)
					console.log('productNums:', retData.productNums);
					var tmpProductList = this.productList;
					console.log('productList前:', tmpProductList);
					for(var key in tmpProductList){
						tmpProductList[key].buy_num = retData.productNums[key].buy_num;
					}
					this.productList = tmpProductList;
					console.log('productList后:', this.productList);
					//更新商品列表(方式二)
					// this.productList.forEach((item, index) =>  {
					// 	//this.$set(item, 'sos', '123')
					// 	this.$set(item, 'buy_num', retData.productNums[index].buy_num)
					// })
					console.log('productList后后:', this.productList);
					this.timer = new Date().getTime(); //重新加载子组件
				}
				this.cartBuyNum = retData.cartBuyNum;
				//this.$refs.shopcart.open();
				console.log('changeNum,end');
				//this.openShopcart();
				// if(realvalue == 0){
				// 	this.cartList.splice(index, 1); //去除该购物车数据
				// 	console.log('cartList:', this.cartList);
				// }
			}
		},
		/**
		 * 显示规格弹窗
		 */
		async showSpec(pid){ //请求并获取数据
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			let param = {
				pid: pid
			};
			let ret = await http.getProductSpec(this.$refs.toast, param, headers, 1);
			var retData = ret.data;
			this.productInfo = retData.productInfo;
			console.log('specinfoList:', retData.specinfoList);
			console.log('specList:', retData.specList);
			if(retData.productInfo.is_spec_open == 1){
				this.gspecList = {
					spec_info_list: retData.specinfoList,
					goods_spec: retData.specList
				}
			}else{
				this.gspecList = {}
			}
			this.specOnLoad = 1;
			console.log('最终组装的gspecList:', this.gspecList);
			this.$refs.specbox.open();
			// if(JSON.stringify(this.productInfo)!='{}' && JSON.stringify(this.gspecList)!='{}'){
			// 	//this.$refs.mychild.toggleSpec();
			// 	this.popupShow = true;
			// }else{
			// 	uni.showToast({
			// 		title: '数据不正确，请稍后再试',
			// 		mask: false,
			// 		duration: 1500
			// 	});
			// }
		},
		/**
		 * 隐藏规格弹窗
		 */
		hidePopup: function() {
			this.$refs.specbox.close();
		},
		/**
		 * 父元素接受子元素（规格）
		 */
		async submitCart(pid, specId, buyNum){ //请求并获取数据,提交事件
			console.log('加入购物车,商品ID:'+pid+';规格ID:'+specId+';购买数量:'+buyNum);
			const token = uni.getStorageSync('token');
			var headers = {"Authorization":"Bearer "+token};
			var param = {
				initPid: pid,
				initSpecId: specId,
				initBuyNum: buyNum
			};
			let ret = await http.doAddAndUpdateCart(this.$refs.toast, param, headers);
			var retData = ret.data;
			console.log('doAddAndUpdateCart操作,请求数据:', retData);
			this.cartBuyNum = retData.cartBuyNum;
			this.$refs.specbox.close();
		},
		/**
		 * 显示购物车
		 */
		async openShopcart(){
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			let param = {
				shid: this.shid
			};
			let ret = await http.getShopCart(this.$refs.toast, param, headers, 1);
			console.log('getShopCart操作，请求数据:', ret);
			if(ret.code == 200){
				var retData = ret.data;
				this.cartList = retData.cartList;
				this.$refs.shopcart.open();
			}
		},
		//清空购物车
		async doClearCart(id){
			var that = this;
			uni.showModal({
				title: '提示',
				content: '确认清空购物车吗？',
				success: function (res) {
					if (res.confirm) {
						that.doClearCartTwo();
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		},
		async doClearCartTwo(){
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			var param = {
				shid: this.shid
			};
			let ret = await http.doClearCart(this.$refs.toast, param, headers);
			var retData = ret.data;
			console.log('请求数据：', retData);
			this.$refs.shopcart.close();
			if(typeof retData != "undefined"){
				//更新商品列表(方式一)
				var tmpProductList = this.productList;
				for(var key in tmpProductList){
					tmpProductList[key].buy_num = retData.productList[key].buy_num;
					//var tmpProdInfo = tmpProductList[key];
					//tmpProdInfo.buy_num = retData.productList[key].buy_num;
					//this.$set(this.productList, key, tmpProdInfo);
				}
				this.productList = tmpProductList;
				console.log('this.productList:', this.productList);
				this.cartBuyNum = retData.cartBuyNum;
				this.timer = new Date().getTime(); //重新加载子组件
			}
		},
		showKefuewmPopup(){
			this.$refs.kefuewmPopup.open();
		},
		hideKefuewmPopup(){
			this.$refs.kefuewmPopup.close();
		},
		openChatDetail(){
			uni.navigateTo({
				url: '/pages/chat/chatDetail?uid='+this.shopInfo.kefu_uid
			})
		},
		onShare(){
			this.$refs.sharePopup.open();
		},
		phoneCall(){
			uni.makePhoneCall({
				phoneNumber: this.shopInfo.phone
			})
		}
	}
}
</script>

<style>
</style>
